package com.qzdsoft.erpcloud.controller.sys;

import java.util.ArrayList;
import java.util.List;

import org.apache.catalina.servlet4preview.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.qzdsoft.erpcloud.service.sys.Permission;
import com.qzdsoft.erpcloud.service.sys.SysRoleMenuService;

/**
 * Created by Admin
 */
@Controller
@RequestMapping("/sys/role/menu")
public class SysRoleMenuController {

    @Autowired
    private SysRoleMenuService sysRoleMenuService;

    @ResponseBody
    @RequestMapping("/edit_execute")
    public Object editExecute(HttpServletRequest request, @RequestParam("roleId") Integer roleId, @RequestParam("menuIds") String menuIds) {
        List<Integer> list = new ArrayList<>();
        for(String s : menuIds.split(",")){
            list.add(Integer.parseInt(s));
        }
        return sysRoleMenuService.save(roleId, list);
    }

}
